const getDate = () => {
	var date = new Date(); // 获取时间
	var year = date.getFullYear(); // 获取年
	var month = date.getMonth() + 1; // 获取月
	var strDate = date.getDate(); // 获取日
	// var day = date.getDate() //
	// var day = '日一二三四五六'.charAt(new Date().getDay()) // 周一返回的是1，周六是6，但是周日是0
	// var hour = date.getHours() // 获取小时
	// var minute = date.getMinutes() // 获取分钟
	// var second = date.getSeconds() // 获取秒
	// 由于部分业务处理 是需要月份日份前面有0 故新增一个函数
	// getNum()
	// console.log('今天星期' + day)
	let currDate = year + "-" + getNum(month) + "-" + getNum(strDate);
	// console.log(year + "-" + getNum(month) + "-" + getNum(strDate));
	return currDate
};

const getYm = () => {
	var date = new Date(); // 获取时间
	var year = date.getFullYear(); // 获取年
	var month = date.getMonth() + 1; // 获取月
	let currDate = year + "-" + getNum(month);
	return currDate
};
const getDateArrNew = function() {
	let date = new Date();
	const year = date.getFullYear()
	date.setDate(date.getDate() + 1);
	let begMonth = new Date().getMonth() + 1
	let begDay = new Date().getDate()
	let day = date.getDate()
	let month = date.getMonth() + 1
	if (day < 10) day = `0${day}`
	if (begDay < 10) begDay = `0${begDay}`
	if (month < 10) month = `0${month}`
	if (begMonth < 10) begMonth = `0${begMonth}`
	let beginTime = `${year}-${begMonth}-${begDay} 00:00:00`
	let beginTimea = `${year}-${begMonth}-${begDay}`
	const endTime = `${year}-${begMonth}-${begDay} 23:59:59`
	const endTimea = `${year}-${month}-${day}`
	console.log(beginTime, endTime);
	return [
		beginTime,
		endTime,
		beginTimea,
		endTimea,
	];
}

const getDateArr = function() {
	let date = new Date();
	const year = date.getFullYear()
	date.setDate(date.getDate() + 1);
	let begMonth = new Date().getMonth() + 1
	let begDay = new Date().getDate()
	let day = date.getDate()
	let month = date.getMonth() + 1
	if (day < 10) day = `0${day}`
	if (begDay < 10) begDay = `0${begDay}`
	if (month < 10) month = `0${month}`
	if (begMonth < 10) begMonth = `0${begMonth}`
	let beginTime = `${year}-${begMonth}-${begDay} 00:00:00`
	let beginTimea = `${year}-${begMonth}-${begDay}`
	const endTime = `${year}-${month}-${day} 00:00:00`
	const endTimea = `${year}-${month}-${day}`
	console.log(beginTime, endTime);
	return [
		beginTime,
		endTime,
		beginTimea,
		endTimea,
	];
}
const getNum = (i) => {
	return i < 10 ? "0" + i : i;
};

// 参数序列化
const querySerialize = (queryData) => {
	return Object.keys(queryData).map(key => key + '=' + params[key]).join('&')
}

module.exports = {
	getDateArrNew,
	getDate,
	getYm,
	getDateArr,
	querySerialize
};